﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AlexandriaPressAdminDataAccessLayer;
using AlexandriaPressAdminObject;


namespace AlexandriaPressAdminBusinessLayer
{
    public class SalesReportBL
    {
        private static int endDay;
        private static DateTime DateStart;
        private static DateTime DateEnd;
        public static List<SalesReportObj> salesByBook(int month, int year)
        {
            if (month == 9 || month == 4 || month == 6 || month == 11)
            {
                endDay = 30;
            }
            else if (month == 2 && year % 4 == 0)
            {
                endDay = 29;
            }
            else if (month == 2 && year % 4 != 0)
            {
                endDay = 28;
            }
            else
            {
                endDay = 31;
            }
            DateStart = Convert.ToDateTime(month + "/01" + "/" + year);
            DateEnd = Convert.ToDateTime(month + "/" + endDay + "/" + year);
            return SalesReportDL.SalesByBook(DateStart, DateEnd);
        }

        public static List<SalesReportObj> salesByGenre(int month, int year)
        {
            if (month == 9 || month == 4 || month == 6 || month == 11)
            {
                endDay = 30;
            }
            else if (month == 2 && year % 4 == 0)
            {
                endDay = 29;
            }
            else if (month == 2 && year % 4 != 0)
            {
                endDay = 28;
            }
            else
            {
                endDay = 31;
            }
            DateStart = Convert.ToDateTime(month + "/01" + "/" + year);
            DateEnd = Convert.ToDateTime(month + "/" + endDay + "/" + year);
            return SalesReportDL.SalesByGenre(DateStart, DateEnd);
        }
    }
}
